
// 获取当前 url 中某个参数的方法
function getURLParam(key){
    var params = location.search;
    if(params.indexOf("?")>=0){
        params = params.substring(1);
        var paramArr = params.split('&');
        for(var i=0;i<paramArr.length;i++){
            var namevalues = paramArr[i].split("=");
            if(namevalues[0]==key){
                return namevalues[1];
            }
        }
    }else{
        return "";
    }
}
//退出登录
function onExit(){
    if(confirm("确认退出？")){
        jQuery.ajax({
            url:"/user/logout",
            type:"POST",
            beforeSend: function(request) {
                request.setRequestHeader("authorization",token);
            },
            data:{},
            success:function(result){
                location.href = "/login.html";
            },
            error:function(err){
                if(err!=null && err.status==401){
                    alert("用户未登录，即将跳转到登录页！");
                    location.href = "/login.html";
                }
            }
        });
    }
}
